home *** CD-ROM | disk | FTP | other *** search
/ Super Shareware Collection / Super Shareware Collection.iso / os_2 / pm22x333.zip / EXAMPLE1.ASM < prev    next >
Assembly Source File  |  1994-02-21  |  3KB  |  98 lines

  1. ; Demonstration of the use of _rmpmirqset.
  2. ; Under DMPI control is not given up with INT33. So the protected mode IRQ
  3. ;  should still be there, unless the DPMI host is buggy.
  4.  
  5.         .386p
  6. code32  segment para public use32
  7.         assume cs:code32, ds:code32
  8.  
  9. include pmode.inc
  10.  
  11. public  _main
  12.  
  13. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  14. ; DATA
  15. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  16. msg0    db      'We are now waiting for a keypress in protected mode. Notice the protected',0dh,0ah
  17.         db      ' mode timer IRQ handler going off (upper right corner of the screen).',0dh,0ah,0dh,0ah,'$'
  18. msg1    db      'Now we are waiting in real mode (not under the control of PMODE). The',0dh,0ah
  19.         db      ' protected mode IRQ handler is gone (unless this is a DPMI system).',0dh,0ah,0dh,0ah,'$'
  20. msg2    db      'We are still in real mode, but a callback has been created using _rmpmirqset',0dh,0ah
  21.         db      ' so the PMODE IRQ handler the IRQ even when PMODE doesn''t have control.',0dh,0ah,0dh,0ah,'$'
  22.  
  23. buf     db      21 dup(?)
  24.  
  25. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  26. ; CODE
  27. ;▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒
  28.  
  29. include pdosmsg.rt
  30.  
  31. ;═════════════════════════════════════════════════════════════════════════════
  32. irq0:                                   ; Protected mode timer IRQ handler
  33.         push eax ds
  34.  
  35.         mov ds,cs:_seldata
  36.         @rlp eax,0b8000h+158            ; Toggle a box on the screen
  37.         xor byte ptr [eax],0fbh
  38.  
  39.         pop ds
  40.         mov al,20h
  41.         out 20h,al
  42.         pop eax
  43.         sti
  44.         iretd
  45.  
  46. ;═════════════════════════════════════════════════════════════════════════════
  47. _main:                                  ; Program starts here
  48.         sti
  49.  
  50.         mov v86r_ax,3                   ; Clear the screen
  51.         mov al,10h
  52.         int 33h
  53.  
  54.         mov edx,offset irq0             ; Set timer vector to our own
  55.         xor bl,bl
  56.         call _setirqvect
  57.  
  58.         mov edx,offset msg0             ; Put first message and wait for key
  59.         call _putdosmsg
  60.         call _pmwaitforkey
  61.  
  62.         mov edx,offset msg1             ; Put next message and wait for key
  63.         call _putdosmsg
  64.         call _rmwaitforkey
  65.  
  66.         mov edi,offset buf              ; Create real mode callback
  67.         xor bl,bl
  68.         call _rmpmirqset
  69.         push edx
  70.  
  71.         mov edx,offset msg2             ; Next message and wait for key
  72.         call _putdosmsg
  73.         call _rmwaitforkey
  74.  
  75.         pop edx                         ; Restore real mode IRQ vector
  76.         call _rmpmirqfree               ; 'mov gs:[4*8],edx' would do as well
  77.  
  78.         jmp _exit
  79.  
  80. ;-----------------------------------------------------------------------------
  81. _pmwaitforkey:                          ; Wait for keypress in protected mode
  82.         mov ax,gs:[41ah]
  83.         cmp ax,gs:[41ch]
  84.         je _pmwaitforkey
  85.         mov gs:[41ch],ax
  86.         ret
  87.  
  88. ;-----------------------------------------------------------------------------
  89. _rmwaitforkey:                          ; Wait for keypress in real mode
  90.         mov v86r_ah,0
  91.         mov al,16h
  92.         int 33h                 ; notice its 33h (gives up PMODE control).
  93.         ret
  94.  
  95. code32  ends
  96.         end
  97.  
  98.